$(document).ready(function () {
	//$("#MedicineTree").treeview({animated:"medium", control:"#contreecontrol1", persist:"location",collapsed:true});
	//$("#CoordinatTree").treeview({animated:"medium", control:"#contreecontrol2", persist:"location",collapsed:true});
	//$("#EmergencyTree").treeview({animated:"medium", control:"#contreecontrol3", persist:"location",collapsed:true});
	//$("#ExternalTree").treeview({animated:"medium", control:"#contreecontrol4", persist:"location",collapsed:true});
	//var treeType="0001";					//指明4棵树中是哪一棵树
	$(".deptclick").click(function (){
		
		//alert($(this).attr('value'));
		var nodeId = $(this).attr('value');
		var treeType=$("#treeType").attr("value");
		//alert(treeType);
		//alert(nodeId);
	//	alert("treeType: "+treeType);
	//	if(treeType=="DI")
	//	  $('#main',window.parent.document).attr("src","../../do/medicineTree_getOAMedicineTreeServiceChildren.action?nodeId="+nodeId);
		   $('#main',window.parent.document).attr("src","../../do/medicineTree_getLocalMedicineTreeServiceChildren.action?nodeId="+nodeId+"&treeType="+treeType);
	});
	
	
	
	//棵树之间切换
	$("#treeType").change(function(){		
		var treeType=$(this).attr("value");
	//	alert(treeType);
		//var nodeId="DI1000000000";
		///do/tree_mtMedicineTreeRoot.action
		location.href= "/ag/do/medicineTree_mtMedicineTreeRoot.action?treeType="+treeType;
		//location.href= "/ag/do/medicineTreeA_mtMedicineTreeRoot.action?treeType="+treeType;
	//	if(myType=="DI") {treeType ="DI";$("#contree2").hide();$("#contree3").hide();$("#contree4").hide();$("#contree1").show();nodeId="DI1000000000";}
		 //if(myType=="0001") {treeType = "0001";$("#contree1").hide();$("#contree3").hide();$("#contree4").hide();$("#contree2").show();nodeId="CR1000000000";}
		//else if(myType=="0002") {treeType = "0002";$("#contree2").hide();$("#contree1").hide();$("#contree4").hide();$("#contree3").show();nodeId="ES1000000000";}
		//else if(myType=="0003") {treeType = "0003";$("#contree2").hide();$("#contree3").hide();$("#contree1").hide();$("#contree4").show();nodeId="EU1000000000";}
	//	$('#main',window.parent.document).attr("src","../../do/medicineTree_getMedicineTreeServiceChildren.action?nodeId="+nodeId+"&treeType="+treeType);
	});
	
	$("#contactTree").treeview( {
		animated : "medium",
		control : "#contactTreecontrol",
		persist : "location"
	});
	
	//查询
	$("#find").click(function(){
		 var goal=document.getElementById("text").value; 
		 if(treeType=="0001") $("#CoordinatTree").find("span:contains('"+goal+"')").css("color","red").css("font-size","20px").parents().show();
		 else if(treeType=="0002")   $("#EmergencyTree").find("span:contains('"+goal+"')").css("color","red").css("font-size","20px").parents().show();
		 else if(treeType=="0003")  $("#ExternalTree").find("span:contains('"+goal+"')").css("color","red").css("font-size","20px").parents().show();
		 var set=$("span:contains('"+goal+"')");		//获取第一个匹配的元素
		 var first = set.first();	
		 if(set.size() != 0)
		 {
		 var y=first[0].offsetTop;		//获取第一个元素的y坐标
		 document.body.scrollTop=y-200;		
		
		 }
		});
	//清除查询	
		$("#clear").click(function(){
			$("span").css("color","").css("font-size","");
		});
});



